package com.qf.xiaomi.dao.impl;

import com.qf.xiaomi.dao.ITbGoodsTypeDao;
import com.qf.xiaomi.pojo.TbGoodsType;
import com.qf.xiaomi.utils.DruidDButils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @Created by 马英超 on 2022/8/17 11:55
 * @author： 马英超
 * @version：v1.0
 * @description:
 */
public class TbGoodsTypeDaoImpl implements ITbGoodsTypeDao {
    /**
     * 查询所有分类信息--用于菜单显示
     * @return
     */
    @Override
    public List<TbGoodsType> queryTbGoodsAll() {
        String sql="select * from tb_goods_type t where t.level=1";
        QueryRunner queryRunner=new QueryRunner();
        try {
            final List<TbGoodsType> queryList = queryRunner.query(DruidDButils.getDruidConn(), sql, new BeanListHandler<>(TbGoodsType.class));
            return queryList;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
